package com.bana.fvs.app.mvp.presenter;

import android.app.Activity;

import com.bana.fvs.app.module.info.entity.UpdatePwdBean;
import com.bana.fvs.app.mvp.contract.ChangePwdContract;
import com.bana.fvs.app.mvp.model.ChangePwdModel;
import com.bana.fvs.app.util.UserInfoUtils;
import com.wei.commonlibrary.net.CommException;
import com.wei.commonlibrary.net.MyDefaultCallback;


/**
 * Created by ${wei} on 2017/4/18.
 * Author : yanftch
 * Date : 2018/3/1
 * Time : 21:22
 * Desc :
 */

public class ChangePwdPresenter extends ChangePwdContract.AbsChangePresenter {

    public void http_updatePwd(Activity activity, String originalPwd, String newPwd) {
        String token = UserInfoUtils.getInstance().getToken(activity);
        mModel.http_updatePwd(token, originalPwd, newPwd).callback(new MyDefaultCallback<UpdatePwdBean>(activity, true) {
            @Override
            public void onError(CommException e) {
                if (null != getView())
                    getView().onError(e);
            }

            @Override
            public void response(UpdatePwdBean updatePwdBean) {
                if (null != getView())
                    getView().onResponse(updatePwdBean);
            }
        });
    }

    @Override
    protected ChangePwdContract.AbsChangeModel createModel() {
        return new ChangePwdModel();
    }
}
